#include <bits/stdc++.h>
using namespace std;
int a[100100],n,ans=999999999;
int main() {
	cin >> n;
	for(int i = 1;i <= n;i++) {
		cin >> a[i];
	}
	for(int i = 1;i < n;i++) {
		ans=min(ans,max(a[i],a[i+1])-min(a[i],a[i+1]));
	}
	cout << ans << endl;
}

